﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;

namespace BusinessStorage
{
    public class OuSuisJeBlobs
    {
        private CloudBlobContainer _BlobContainer;

        public CloudBlobContainer BlobContainer
        {
            get { return _BlobContainer; }
            set { _BlobContainer = value; }
        }
        public OuSuisJeBlobs(CloudBlobContainer blobcontainer)
        {
            BlobContainer = blobcontainer; 
        }

        public bool CreateBlobFromStream(System.IO.Stream str,String BlobName)
        {
            CloudBlockBlob blob = BlobContainer.GetBlockBlobReference(BlobName);
            blob.UploadFromStream(str);
           
            //return blob.Uri.ToString();
            return true;
        }
        public System.IO.Stream GetBlobStream(String BlobName)
        {
            CloudBlockBlob blob = BlobContainer.GetBlockBlobReference(BlobName);
            System.IO.MemoryStream str = new System.IO.MemoryStream();
            blob.DownloadToStream(str);
            return str;
        }
    }
}
